<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>父子级组件</title>
    <script src="vue.js"></script>
  </head>
  <body>
    <div id="app">
      <parent><child></child></parent>
    </div>
    <script>
      var childNode = {
        template: "<div>这是子组件</div>",
      };
      var parentNode = {
        template: `
      <div>
          <child></child>
      </div>
      `,
        components: {
          child: childNode,
        },
      };
      // 创建根实例
      var vm = new Vue({
        el: "#app",
        components: {
          parent: parentNode,
        },
      });
    </script>
  </body>
</html>
